from flask import render_template, request

from tzq.document_management_system import dms_bp
from tzq.document_management_system.model.permission_model import Permission


@dms_bp.route('/')
def dms_index():
    client_ip = request.remote_addr
    permission_temp = Permission.query.filter(Permission.ip == client_ip).first()
    user_name = "未登记用户"
    user_type = "游客"
    if permission_temp:
        user_name = permission_temp.user_name
        user_type = permission_temp.user_type
    return render_template('dms_index.html',
                           ip=client_ip,
                           user_name=user_name,
                           user_type=user_type)


@dms_bp.route('/console')
def dms_console():
    return render_template('dms_console.html')


@dms_bp.route('/oneClickExport/')
def one_click_export():
    return render_template('one_click_export.html')


@dms_bp.route('/message/')
def message():
    return render_template('message.html')


@dms_bp.route('/log/')
def log():
    return render_template('log.html')


@dms_bp.route('/catalogExportAll/')
def catalog_export_all():
    return render_template('catalog_export_all.html')


@dms_bp.route('/catalog/')
def catalog():
    return render_template('catalog.html')


@dms_bp.route('/catalogModify/')
def catalog_modify():
    return render_template('catalog_modify.html')


@dms_bp.route('/catalogDelete/')
def catalog_delete():
    return render_template('catalog_delete.html')


@dms_bp.route('/functionExportAll/')
def function_export_all():
    return render_template('function_export_all.html')


@dms_bp.route('/function/')
def function():
    return render_template('function.html')


@dms_bp.route('/functionCatalog/')
def function_catalog():
    return render_template('function_catalog.html')


@dms_bp.route('/functionDimension/')
def function_dimension():
    return render_template('function_dimension.html')


@dms_bp.route('/functionPermission/')
def function_permission():
    return render_template('function_permission.html')


@dms_bp.route('/lookupExportAll/')
def lookup_export_all():
    return render_template('lookup_export_all.html')


@dms_bp.route('/lookupClassify/')
def lookup_classify():
    return render_template('lookup_classify.html')


@dms_bp.route('/lookupItem/')
def lookup_item():
    return render_template('lookup_item.html')


@dms_bp.route('/lookupDelete/')
def lookup_delete():
    return render_template('lookup_delete.html')


@dms_bp.route('/lookupDisable/')
def lookup_disable():
    return render_template('lookup_disable.html')


@dms_bp.route('/roleExportAll/')
def role_export_all():
    return render_template('role_export_all.html')


@dms_bp.route('/role/')
def role():
    return render_template('role.html')


@dms_bp.route('/roleFunction/')
def role_function():
    return render_template('role_function.html')


@dms_bp.route('/roleFunctionDelete/')
def role_function_delete():
    return render_template('role_function_delete.html')


@dms_bp.route('/propertyPlan/')
def property_plan():
    return render_template('property_plan.html')


@dms_bp.route('/propertyIns/')
def property_ins():
    return render_template('property_ins.html')


@dms_bp.route('/propertyCommon/')
def property_common():
    return render_template('property_common.html')


@dms_bp.route('/propertyDataPlan/')
def property_data_plan():
    return render_template('property_data_plan.html')


@dms_bp.route('/propertyMonitor/')
def property_monitor():
    return render_template('property_monitor.html')


@dms_bp.route('/propertyEod/')
def property_eod():
    return render_template('property_eod.html')


@dms_bp.route('/propertyMonitorHis/')
def property_monitor_his():
    return render_template('property_monitor_his.html')
